package com.sdp.wx.controller;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.sdp.core.bizc.db.Query;
import com.sdp.core.bizc.vo.DataCenter;
import com.sdp.core.bizc.vo.Result;
import com.sdp.wx.db.wx_wz_arrival_detail.entity.WxWzArrivalDetail;
import com.sdp.wx.db.wx_wz_arrival_detail.service.IWxWzArrivalDetailService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zsp
 * @since 2024-01-25
 */
@RestController
@RequestMapping("/WxWzArrivalDetailController")
public class WxWzArrivalDetailController {

	@Autowired
	private Query query;
	
	@Autowired
	private IWxWzArrivalDetailService iWxWzArrivalDetailService;
	
	@PostMapping(value = "/page")
	public Result<?> page(@RequestBody DataCenter dataCenter) {
		return Result.ok(query.page(iWxWzArrivalDetailService, WxWzArrivalDetail.class, dataCenter));
	}
	
	@PostMapping(value = "/list")
	public Result<?> list(@RequestBody DataCenter dataCenter) {
		return Result.ok(query.list(iWxWzArrivalDetailService, WxWzArrivalDetail.class, dataCenter));
	}
	
	/**
	 * 根据到货单编号，查询到货的器材信息
	 * @param planCode
	 * @return
	 */
	@GetMapping(value = "/queryArrivalDetailByArrivalCode")
	public Result<?> queryArrivalDetailByArrivalCode(@RequestParam(name="arrivalCode",required=true) String arrivalCode) {
		if(StringUtils.isEmpty(arrivalCode)) {
			return Result.error("到货单编号为空");
		}
		List<WxWzArrivalDetail> li = iWxWzArrivalDetailService.queryWxWzArrivalDetailByCode(arrivalCode);
		if(li==null || li.size()==0) {
			return Result.error("此到货单没有到货的器材信息，请确认");
		}
		return Result.ok(li);
	}
}

